<template>
  <div style="width:700px">
    <div class="right_div_title">
      <p>我的文章</p>
    </div>
    <el-card v-if="articleList.length === 0" class="notWrite">
      <el-tooltip class="item" effect="dark" content="点击去写文章" placement="bottom">
        <el-link :underline="false" href="http://localhost:9528/#/publishArticle">您还没有写过文章</el-link>
      </el-tooltip>
    </el-card>
    <el-card v-else>
      <Article v-for="article in articleList" :key="article.article.createTime" :article="article" />
    </el-card>
  </div>
</template>

<script>
import Article from '../article/index.vue'
import { myArticles } from '@/api/article'
export default {
  components: { Article },
  data() {
    return {
      articleList: []
    }
  },
  computed: {

  },
  mounted: function() {
    this.getArticleList()
  },
  methods: {
    getArticleList() {
      myArticles({ userId: this.$store.state.user.id, pageSize: null }).then(res => {
        this.articleList = res.data
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.right_div_title p {
    height: 48px;
    width: 100%;
    line-height: 48px;
    font-size: 16px;
    color: #999;
    background: #fff;
    border-radius: 10px;
    text-indent: 30px;
}
.article_title{
    font-size: 20px;
    font-weight: bold;
}
.article_content{
    font-size: 14px;
    color: #a1afc9;
}
.notWrite {
  text-align: center;
  color: #a1afc9
}
</style>
